﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MediaSage.Lib.Client.Config;
using MediaSage.Lib.Database.Entities.Client;
using MediaSage.Lib.UIFramework.Dialog.Entities;

namespace MediaSage.Lib.UIFramework.Theme
{
    /// <summary>
    /// Encapsulates a theme, contains all the objects that will be drawn by the UI
    /// </summary>
    public abstract class ThemeObject
    {
        protected Client.Config.Configuration config;
        protected ClientLogger logger;

        public string ThemeName;

        public ThemeEntity ThemeDBEntity;

        /// <summary>
        /// Colors used format is:
        ///     ColorName, ColorString like:
        ///            "TextColor", "255,255,255,255"
        ///             or
        ///             "TextColor", "White"
        /// </summary>
        public IDictionary<string, string> Colors;

        // The following define the different theme objects that are possible

        /// <summary>
        /// Defines the Header Font
        /// </summary>
        public string H1Font;

        /// <summary>
        /// Defines the Sub-Header Font
        /// </summary>
        public string H2Font;

        /// <summary>
        /// Defines standard text font
        /// </summary>
        public string TextFont;

        /// <summary>
        /// Defines bold standard text
        /// </summary>
        public string BoldTextFont;

        /// <summary>
        /// Color of Heading Text
        /// </summary>
        public string HeadingColor;

        /// <summary>
        /// Color of basic text
        /// </summary>
        public string TextColor;

        /// <summary>
        /// Color of the background
        /// </summary>
        public string BackgroundColor;

        public ThemeObject(Client.Config.Configuration configuration)
        {
            this.config = configuration;
            logger = config.Logger;
        }

        /// <summary>
        /// Draws a modal dialog based on a message entity
        /// </summary>
        /// <param name="dialogEntity">Information pertaining to what/how to draw the dialog from the database</param>
        /// <returns>True if successful, false if not (The dialogEntity will be rewritten to the DB)</returns>
        public abstract bool DialogWindow(DialogMappingEntity dialogEntity);

        /// <summary>
        /// Draws a non-modal dialog
        /// </summary>
        /// <param name="dialogEntity">Caption is ignored</param>
        /// <returns></returns>
        public abstract bool NotificationWindow(DialogMappingEntity dialogEntity);

        /// <summary>
        /// Initializes the color palette
        /// The base one initializes the default colors
        /// </summary>
        /// <returns></returns>
        protected void initializeColors()
        {
            HeadingColor = "White";
            TextColor = "White";
            BackgroundColor = "DarkBlue";
        }

        /// <summary>
        /// Initializes the font pallette
        /// The base one initializes the default colors
        /// </summary>
        /// <returns></returns>
        protected void initializeFonts()
        {
            H1Font = "<Font Name=\"H1Font\" FontName=\"Segoe Media Center\" FontSize=\"32\" FontStyle=\"Bold\">";
            H2Font = "<Font Name=\"H2Font\" FontName=\"Segoe Media Center\" FontSize=\"24\" FontStyle=\"Bold\">";
            TextFont = "<Font Name=\"TextFont\" FontName=\"Segoe Media Center\" FontSize=\"24\" FontStyle=\"None\">";
            BoldTextFont = "<Font Name=\"TextFont\" FontName=\"Segoe Media Center\" FontSize=\"24\" FontStyle=\"Bold\">";
        }
    }
}